function linkchecker() {
   var txt = new String(document.getElementById('listlinks').value);
   var links = txt.split("\n");
   var allmu = [];

   document.getElementById('checked_links').innerHTML = links.length;

   var numberofmulinks = 0;
   var mymegauploadRegExp0 = /http\:\/\/www\.megaupload\.com\/(?:|..\/)\?d=.{8}(\/|)/;

    var checkedlinksRegExpid = /(alive_link|adead_link|unava_link)/;
    muid = 0;
    for (var i = links.length - 1; i >= 0; i--) {
		// megaupload 
        if (links[i].search(mymegauploadRegExp0) != -1)  { //if (links[i].href.search(mymegauploadRegExp) != -1) {
            var urll = links[i];
            numberofmulinks++;
            urll = urll.replace(/^.*?http:\/\/www\.(?:megaupload|megarotic|megaporn)\.com\/(?:|..\/)\?d=/gi, 'id' + muid + '=');
            urll = urll.replace(/^.*?http%3A%2F%2Fwww\.(?:megaupload|megarotic|megaporn)\.com\/(?:|..\/)\?d=/gi, 'id' + muid + '=');
            urll = urll.replace(/%2F/gi, '/');
            urll = urll.replace(/%3A/gi, ':');
            muid++;
            var myString = '' + numberofmulinks + ''; //if (myString.search(/\&id99/) != -1) //mporei mexri 99 apotelesmata tin fora
            allmu.push(urll);
        }
    }

    allmu = allmu.join();
    allmu = allmu.replace(/,/gi, '&');
    var allmu = allmu.split("xxxczxczxcsasdasdasdx4234");
    if (numberofmulinks > 0) {
        alive_link_png = 'data:image/png;base64,' + // http://i28.tinypic.com/dq5emx.png http://hosts1.atspace.com/accept.png
        'iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAAL' + 'EwEAmpwYAAAAB3RJTUUH2AMJCQY36Sc4vgAAAlRJREFUeNpV0r9PE3EABfD3veu1lJYr15ZCoBHBqJBAMEbjL0hY' + 'FAkyOAmJMUYd/Q+cXF1wYPQPILppYkKIRARiMDGoaAKimBaKHMWDXnu93venE0Tf9Ib3tg/BP7m3NGgwxtKcM4vy' + 'IKSk4BBqnwux9/LGKjvckcNy9/1Akgk2ZJHMWNyw+qWUMSGZ51R2FzbdX1NSyOnZWznn6HRn8UqSCv6gLdz58GSs' + 'L2voURJIirAWhh+U1fLO4tbKztdJIvHsw/1NR7/97pJBOR9tDXc+6rMGsg4vkd3AhkMdVJgLounkdKLHdL1S13Zp' + 'dyMzbK5pnNF0I0mNn4r3Ze3AJrZvo0zL8KkPyil6rTOgipFzrRezLXVt4zWKtBbwWjIeTgyEQlHiUhepcBpNkSaY' + 'ehxX20Yw2HYd3VYP6iNRYhrpAeojGfJqvs7rRIyKGpSUGOm4iYgWwX7wB72ps/hWXMZCbgaNkUYQrseUr3SNB0JQ' + 'Rj0DBnSlYWN/DcfNEzifuYzVvS94vf4cVeoiBB2ScY8IiBBnytk7KM5XG8qj9SRClrbnUKNVZKLNWMjPwKkWkYk1' + '46BSUbZrz0PC0ZuHzaBYLokq9S90p3pMJRnJl35gtfgZQnAko0lY4WY1+2lu63s+N0EE+agXXrkydc3czjtF7noH' + 'XccSx82mWIY0hBpgRVMIalK9WX67tfJzfZJo5EVuouAdieh4kk3KQA21J1rGmuoy/UToMSG5t+vaC5u/7Smikenc' + '04LzHyMAaH+cNcBVGgyWClSIgHAA+2DYy00Wjuz9Bce5MucW9xnuAAAAAElFTkSuQmCC';
        adead_link_png = 'data:image/png;base64,' + //http://i27.tinypic.com/t96wq8.png http://hosts1.atspace.com/dead.png
        'iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAAL' + 'EwEAmpwYAAAAB3RJTUUH2AMJCQkjdGXwDAAAAcpJREFUeNptkj9PFHEQhp/ZBcIhxyKHYgNCYUxogE0OpdDGxsQC' + 'Y6e5ggS1Mn4Ce621u7MCYqOdX4DkSLTBqwyNiQmJBiJiDjmWP/ub1+IAMXGqmTx5M5nJY5wpwRiQHPfoL2rG8PVk' + 'sDOBlKRYZWgwxcwkIQlc0o+fDe3sPu6E1dOQIGWg/yUT4zOUBiLtHYAHFBy6YvRrW+Hzl4/e/P2kAJ8iwRhJscrE' + '+AzDwxG3Z2E/oO9bKMvhzj104aLZ1dFr9PZUWzDWASQMDaYqDZjdvAWzd2HkMlpcJKpUsMlJdHiI3i1Ffr4v9d29' + 'pEMnt7UyfOkNNjKKTU8Tl8tghq+sEGqvUZwjZA5EAiShPIetLXxhASSIY3An1Gr4xkabq70iar9OkOeoWCSqVMAM' + '8hzMiObnIUnQ0RFyR0DkgNylzhh7cB+bmsLrdQ7n5gj1OlG5TPxoHro7kUsC4mdQUB5u0NdziW/r5q2M/PkLfG2N' + 'sLwMkRHevyVkWQib26t+FJYMIIOUvt5XdmXkunXEke/sQchRCNDdRfAQ8vXND97af1qCxqkRLUj9XKFq/cUUMMmR' + 'QHKFZquh7OBhCRr/aATQ/I97foxKZ9z7A9QA5voyr3dtAAAAAElFTkSuQmCC';
        NDSTUSEROR_png = 'data:image/png;base64,' + // or temporary anavailable
        'iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAAL' + 'EwEAmpwYAAAAB3RJTUUH2AQJDBgxYO68rwAAAZNJREFUeNptkr9LW1EcxT/3GhOTKIG8QTpm8B8IIoJTFkFwsXVy' + 'UaxFJHYoFzJYUVFHn4sKtoidCoKtIigWOtQOhRKowaFzJwcF0VeJ+fFe7nUwP57R7/S9nO+595z7PQJfGUgAsWqP' + 'aUBOC/yrHQI+QjKTXc7GQq4EhP+uKzdUcbtnelvhDzXQQHL2bCkbxhOA5GmZ24LUC73zPWE4lQYSmexynaCmjh5N' + 'q9FdANER1uL9j7nfeUhIIFaVJNXEPrguKvPzgfD2G0iBGt8DkPG4CGiIyapZAWBvDUEoBOfnqPQxaANxC3v7Ze1h' + 'oQFpmsTbGwMQicLNNeTz2HaKYuO/4DnTauwLeC6i8wW4ZdSbA9rw/GtB6kaPmjyESATKZVZWUxAMQqnI9MTXOqdG' + 'cvRFoSw8o+0Pg1DxsD+PcFcJYH8aphSNsr71CkAH/17danAEQAGSa98zv7x4W9AIpGkRzap18cKU3vUv9lmQq6N5' + 'SH7cSZ8Uuqx205SI1rPL/6/HN1MW5GiKC84z2at6dixf9u4B/PqUtJuX27QAAAAASUVORK5CYII=';
        loading_img = 'data:image/gif;base64,' + 'R0lGODlhDQANAMZfADuHMTyMMz6SM0uQPkySQFGVSFSXTEaeN1OaSVOaSk+gQlWfTlSjS1apRVWsOlqtR2K3SWG6Qm+2WWm8T3O4' + 'XGfASXe5YW/BVXm9Y2zFTm7EY3jBZ4a8dnHGWHPGWHDGZIHAboe+eIHBboXAb3PIWYXBcHbIXXPIaHfHaoPDcYnBenzHb3jKX4fE' + 'c3fKbHvJbn7IcHzLcH3LcH3McZHFfYjJd47Hf5bGhpDJgIXNeZXIgobOfJPKgZbKhJfKhInPfYrRforRf5jMipPPhJjOiJbRipfS' + 'h5XTiJjTiJbUi5zSj5rTjZvWkJzWkZ3WkafVnKHYla/bprbgrb3es7zitb/itsfnwcvmxMzmxdHszdju1PT68/b79fj89/z9+///' + '////////////////////////////////////////////////////////////////////////////////////////////////////' + '/////////////////////////////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQBZAB/ACwAAAAADQANAAAHd4B/goOEhYIZLCYeEYZ/' + 'JEhOSU1DEIUdUEEzLjI/Sg+DFUZAJx8aKFJFNgeCHkwxOzkrVFxVRAyCF0cvWVpWW1cpPAuCE0swUV1eWCIYPgmCDjg1G09TIBIl' + 'IQGDDUItGBQWIzcEhQoqPTQ6HAONAggGBQCN9IKBACH5BAFkAH8ALAAAAAANAA0AAAdjgH+Cg4SFghksJh4Rhn8kSE5JTUMQhR1Q' + 'QTOaP0oPgxVGQJqjRjYHgh5MMaOaMUQMghdHq6wzPAuCE0u0ozE+CYIOODW1RiEBgw1CLTHNMTcEhQoqPTQ6HAONAggGBQCN4IKB' + 'ADs=';    
		//GM_addStyle("#alive_link_checked, #alive_link {background:transparent url(" + alive_link_png + ") no-repeat scroll 100% 50%;padding-right:15px;}");
        //GM_addStyle("#adead_link {background:transparent url(" + adead_link_png + ") no-repeat scroll 100% 50%;padding-right:15px;}");
        //GM_addStyle("#unava_link {background:transparent url(" + NDSTUSEROR_png + ") no-repeat scroll 100% 50%;padding-right:15px;}");
        //GM_addStyle(".loading {background:transparent url(" + loading_img + ") no-repeat scroll 100% 50% !important;padding-right:15px;}");

        getmulinkschecked(allmu);

    }
}

  function getmulinkschecked(allmu) {
      var str = '';
      console.log(allmu);
        for (var i = allmu.length - 1; i >= 0; i--) { // can check 10000 Bites of links so all.join('\n').length <= 10000

            datas = allmu[i];
            window.setTimeout(function() {
                $.ajax({
                    type: 'POST',
                    url: 'http://megaupload.com/mgr_linkch' + 'eck.php',
                    data: datas,
                    success: function(result) {
                        res = result.responseText;
                        res = res.replace(/\d=www.megaupload.com&\d=www.megarotic.com/, '');
                        var recieved = new Array();
                        recieved = res.split('&id');
                        var pagelinks = new Array();
                        pagelinks = datas.split('id');
                        var alltogethernow = new Array();
                        for (var y = recieved.length - 1; y >= 0; y--) {
                            pagelinks[y] = 'file' + pagelinks[y];
                            alltogethernow.push(pagelinks[y] + '=' + recieved[y]);
                        }
                        alltogethernowstr = alltogethernow.join('+');
                        livelink = alltogethernowstr.match(/file\d{1,}=(........)(?:&|)=\d{1,}=0&s=(\d*)&d=\d&n=(.*?)\+/g);
                        notfound = alltogethernowstr.match(/file\d{1,}=(........)(?:&|)=\d{1,}=1/g);
                        tempanav = alltogethernowstr.match(/file\d{1,}=(........)(?:&|)=\d{1,}=3/g);
                        if (notfound) {
                            var fotfoundlinks = new Array();
                            for (var i = notfound.length - 1; i >= 0; i--) {
                                var string = notfound[i];
                                var regex = /file\d{1,}=(........)(?:&|)=\d{1,}=1/;
                                matchArray = string.match(regex);
                                fotfoundlinks.push(matchArray[1]);
                                // cosecha
                                str = str + matchArray[1] + " Failed<br />"
                            }
                            if (fotfoundlinks) {
                                //DiplayTheDeletedLinks(fotfoundlinks);
                            }
                        }
                        if (tempanav) {
                            var tempanavlinklinks = new Array();
                            for (var i = tempanav.length - 1; i >= 0; i--) {
                                var string = tempanav[i];
                                var regex = /file\d{1,}=(........)(?:|&)=\d{1,}=3/;
                                matchArray = string.match(regex);
                                tempanavlinklinks.push(matchArray[1]);
                                // cosecha                                
                                str = str + matchArray[1] + " Tempanav<br />"                                
                            }
                            if (tempanavlinklinks) {
                                //DiplayTheTempAvailableLinks(tempanavlinklinks);
                            }
                        }
                        if (livelink) {
                            var livelinklinks = new Array();
                            var livelinklinksplus = new Array();
                            for (var i = livelink.length - 1; i >= 0; i--) {
                                var string = livelink[i];
                                var regex = /file\d{1,}=(........)(?:&|)=\d{1,}=0&s=(\d*)&d=\d&n=(.*?)\+/;
                                matchArray = string.match(regex);
                                livelinklinks.push(matchArray[1]);
                                livelinklinksplus.push('+%%+id=' + matchArray[1] + '+%%+size=' + matchArray[2] + '+%%+name=' + matchArray[3] + '+%%+##');
                                // cosecha                                
                                str = str + matchArray[1] + " Correcto<br />" 
                            }
                            if (livelinklinksplus) {
                                //DiplayTheMULiveLinks(livelinklinksplus);
                            } //if (livelinklinks){
                            //DiplayTheLiveLinks(livelinklinks);
                            //}
                        }
                        document.getElementById('checked_links').innerHTML = str;                        
                    }
                });
            },
            1);
        }
    }
    
  function DiplayTheDeletedLinks(fotfoundlinks) {
        var xpathoffotfoundlinks = "//a[contains(@href,\'" + fotfoundlinks.join('\') or contains(@href,\'') + "\')]";
        var allLinks, thisLink;
        allLinks = document.evaluate(xpathoffotfoundlinks, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
        for (var i = 0; i < allLinks.snapshotLength; i++) {
            var thisLink = allLinks.snapshotItem(i);
            //if (Show_black_backround_in_dead_links == 'yes') {
            	if (Show_black_backround_in_dead_links) {
                thisLink.style.backgroundColor = 'Black';
                thisLink.style.color = 'Azure';
            }
            	if (Show_line_through_in_dead_links) {
                thisLink.style.textDecoration = 'line-through';
            }
                if (! (thisLink.href.match(/(google|search%3Fq%3D|search\?q=)/))) {
                thisLink.id = 'adead_link';
            }
                if (No_live_links) {	
                delinkify(allLinks.snapshotItem(i), thisLink.id);
            }
        } // another way slower 
    }
    

